public class Soultion {
    public int divisorSubstrings(int num, int k) {
        char[] ret=intToCharArray(num);
        char[] chararray=new char[k];
        int i=0;
        int tmp=0;
        int count=0;
        while(i<ret.length-1){
            int j=0;
            tmp=i+k;
            for(;i<tmp;i++){
                if(i>=ret.length){
                    break;
                }
                chararray[j]=ret[i];
                j++;
            }
            String s=new String(chararray);
            int flag=Integer.parseInt(s);
            if(num%flag==0){
                count++;
            }
            i=i-(k-1);
        }
        return count;
    }
    public static char[] intToCharArray(int num) {
        boolean isNegative = num < 0;
        if (isNegative) {
            num = -num;
        }
        int numflag=num;
        int len =0;
        while (num > 10) {
            num=num/10;
            len++;
        }
        StringBuilder sb = new StringBuilder();
        while (numflag > 0) {
            int i=0;
            for(;len>=0;len--){
                int flag=0;
                i=len;
                int j=(int)Math.pow(10,i);
                if(len==0){
                    flag=numflag%10;
                }else{
                    flag=numflag/j;
                    numflag=numflag-(j*flag);
                }
                sb.append(flag);
            }
        }
        if (isNegative) {
            sb.append('-');
        }
        return sb.toString().toCharArray();
    }

    public static void main(String[] args) {
       int  num = 240, k = 2;
       Soultion soultion=new Soultion();
       int ret=soultion.divisorSubstrings(num,k);
        System.out.println(ret);
    }
}
